/**
  * Author: Mei
  * Date: 2020-12-01 19:24
  * Description: 
  *
  */
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>

using namespace std;

void process(const vector<int> &vec, function<void(int)> fun) {
    for (auto &v : vec) {
        fun(v);
    }
}

void print(int num) {
    cout << num << " " << endl;
}

int main() {
    vector<int> vec(10);
    iota(vec.begin(), vec.end(), 1);
    process(vec, print);
    int sum = 0;
    process(vec, [sum](int num) {
        sum += num;

    });
    cout << "sum = " << sum << endl;

    return 0;
}